package run.jingjing.websocket.model;

import javax.websocket.Session;
import java.util.Objects;

/**
 * @author: jingjing
 * @date: 2021/6/24
 * @description:
 */
public class LWsSession {

    /**
     * userId of endpoint
     */
    protected Integer userId;

    /**
     * application token of endpoint
     */
    protected String token;

    /**
     * topic of endpoint
     */
    protected LWsTopic topic;

    /**
     * session of endpoint
     */
    protected Session session;

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public LWsTopic getTopic() {
        return topic;
    }

    public void setTopic(LWsTopic topic) {
        this.topic = topic;
    }

    public Session getSession() {
        return session;
    }

    public void setSession(Session session) {
        this.session = session;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        LWsSession that = (LWsSession) o;
        return Objects.equals(userId, that.userId) &&
                Objects.equals(token, that.token) &&
                Objects.equals(topic, that.topic) &&
                Objects.equals(session.getId(), that.session.getId());
    }

    @Override
    public int hashCode() {
        return Objects.hash(userId, token, topic, session.getId());
    }
}
